<!--
 * @Description: 数据大屏
 * @Author: DXV-RGWU-TUFH-RFCY-IEGMYY
 * @Date: 2023-07-28 14:41:43
 * @LastEditTime: 2023-08-14 19:26:07
 * @LastEditors: DXV-RGWU-TUFH-RFCY-IEGMYY
-->

<template>
  <div class="lb-count-index rel">
    <div id="load" v-if="!isLoad">
      <div class="load_img">
        <!-- 加载动画 -->
        <img class="jzxz1" src="../../assets/count/jzxz1.png" />
        <img class="jzxz2" src="../../assets/count/jzxz2.png" />
      </div>
    </div>
    <block v-if="isLoad">
      <div class="count-nav flex-center c-base abs">可视化数据平台</div>
      <div class="count-text flex-center c-base abs">
        <span class="text-right">{{ day }}</span>
        <span class="flex-center">{{
          ['周天', '周一', '周二', '周三', '周四', '周五', '周六'][week]
        }}</span>
        <span>{{ time }}</span>
      </div>
      <div class="count-infos">
        <div class="item-column">
          <div class="pd-lg rel" style="height: 20vh">
            <div class="common-panel abs"></div>
            <div
              class="flex-center count-list technician"
              style="height: calc(20vh - 32px)"
            >
              <div class="item-chlid flex-center flex-column">
                <div class="num">{{ detail.coach.total_count }}</div>
                <div class="text">
                  {{ `${$t('action.attendantName')}总数` }}
                </div>
              </div>
              <div class="item-chlid flex-center flex-column">
                <div class="num">{{ detail.coach.work_count }}</div>
                <div class="text">工作中</div>
              </div>
              <div class="item-chlid flex-center flex-column">
                <div class="num">{{ detail.coach.rest_count }}</div>
                <div class="text">休息中</div>
              </div>
              <div class="item-chlid flex-center flex-column">
                <div class="num">{{ detail.coach.notcertified_count }}</div>
                <div class="text">未认证</div>
              </div>
            </div>
          </div>
          <div class="rel mt-lg" style="height: 24vh; padding: 16px 30px">
            <div class="common-panel abs"></div>
            <div class="common-title rel f-paragraph c-base">订单总览</div>
            <div
              class="flex-center flex-column"
              style="height: calc(24vh - 32px)"
            >
              <div class="count-list order">
                <div class="item-chlid">
                  <div class="num">{{ detail.order.today_order_cash }}</div>
                  <div class="text">
                    <i class="icon-dot" style="color: #4c9bfd"></i
                    >今日营收（元）
                  </div>
                </div>
              </div>
              <div style="height: calc(24vh - 164px)"></div>
              <div
                class="flex-x-between count-list order"
                style="width: 100%; padding: 0 10px 15px 0"
              >
                <div class="item-chlid">
                  <div class="num">{{ detail.order.today_order_count }}</div>
                  <div class="text">
                    <i class="icon-dot" style="color: #ed3f35"></i>今日订单量
                  </div>
                </div>
                <div class="item-chlid">
                  <div class="num">{{ detail.order.total_order_cash }}</div>
                  <div class="text">
                    <i class="icon-dot" style="color: #2bcd8e"></i
                    >累计业绩（元）
                  </div>
                </div>
                <div class="item-chlid">
                  <div class="num">{{ detail.order.total_order_count }}</div>
                  <div class="text">
                    <i class="icon-dot" style="color: #ffa500"></i>总订单量
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div
            class="rel mt-lg"
            style="height: calc(100vh - 44vh - 108px); padding: 16px 30px"
          >
            <div class="common-panel abs"></div>
            <div class="common-title rel f-paragraph c-base">求救通知</div>
          </div>
        </div>
        <div class="item-column">
          <div style="height: calc(100vh - 40vh - 132px)">
            <div class="f-paragraph c-base">当前开放城市</div>
            <div class="chart">
              <div class="geo"></div>
            </div>
          </div>
          <div class="rel mt-lg" style="height: 40vh; padding: 16px 30px">
            <div class="common-panel abs"></div>
            <div class="common-title rel f-paragraph c-base">订单统计</div>
            <div style="width: 100%; height: calc(40vh - 50px); color: #fff">
              <sales-echarts :datas="detail.order_data" />
            </div>
          </div>
        </div>
        <div class="item-column">
          <div class="rel" style="height: 28vh; padding: 16px 30px">
            <div class="common-panel abs"></div>
            <div style="width: 100%; height: calc(30vh - 50px); color: #fff">
              <users-echarts :datas="detail.user_data" />
            </div>
          </div>
          <div class="rel mt-lg" style="height: 29vh; padding: 16px 30px">
            <div class="common-panel abs"></div>
            <div class="common-title rel f-paragraph c-base">
              {{ $t('action.attendantName') }}业绩排行
            </div>
          </div>
          <div
            class="rel mt-lg"
            style="height: calc(100vh - 57vh - 108px); padding: 16px 30px"
          >
            <div class="common-panel abs"></div>
            <div class="common-title rel f-paragraph c-base">最新订单</div>
          </div>
        </div>
      </div>
    </block>
  </div>
</template>
<script>
import moment from 'moment'
import salesEcharts from './salesEcharts'
import usersEcharts from './usersEcharts'
import orderEcharts from './orderEcharts'
export default {
  components: {
    salesEcharts,
    usersEcharts,
    orderEcharts
  },
  data () {
    return {
      isLoad: false,
      detail: {},
      timer: null,
      day: '',
      week: '',
      time: ''
    }
  },
  async created () {
    this.initIndex()
  },
  destroyed () {
    if (this.timer) clearInterval(this.timer)
  },
  methods: {
    async initIndex () {
      if (this.timer) clearInterval(this.timer)
      let [detail, order] = await Promise.all([this.$api.survey.dataScreen(), this.$api.survey.orderData({ day: 3 })])
      let { data } = detail
      data.order_data = order.data
      this.detail = data
      this.day = moment(new Date().getTime()).format('YYYY-MM-DD')
      this.week = new Date().getDay()
      this.timer = setInterval(() => {
        let unix = moment(new Date().getTime()).format('HH:mm:ss')
        this.time = unix
      }, 1000)
      this.isLoad = true
    }
  },
  filters: {
    handleTime (val, type) {
      let time = type === 1 ? moment(val * 1000).format('YYYY-MM-DD') : type === 2 ? moment(val * 1000).format('HH:mm:ss') : moment(val * 1000).format('YYYY-MM-DD HH:mm:ss')
      return time
    }
  }
}
</script>

<style lang="scss" scoped>
@font-face {
  font-family: 'electronicFont'; /* 字体名称 */
  src: url('https://lbqny.migugu.com/admin/font/DS-DIGIT.TTF'); /* 字体文件相对路径 */
}
@font-face {
  font-family: 'taiwaiFont'; /* 字体名称 */
  src: url('https://lbqny.migugu.com/admin/font/TW-Kai-98_1.ttf'); /* 字体文件相对路径 */
}
@font-face {
  font-family: 'icomoon'; /* 字体名称 */
  src: url('https://lbqny.migugu.com/admin/font/icomoon.ttf') format('truetype'); /* 字体文件相对路径 */
}
[class^='icon-'],
[class*=' icon-'] {
  /* use !important to prevent issues with browser extensions that change fonts */
  font-family: 'icomoon' !important;
  speak: none;
  font-style: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;

  /* Better Font Rendering =========== */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-dot:before {
  content: '\e900';
}

.lb-count-index {
  width: 100%;
  height: 100vh;
  line-height: 1.15;
  font-size: 0.5rem;
  margin: 0;
  padding: 0;
  background-repeat: no-repeat;
  background-position: 0 0 / cover;
  background-color: #101129;
}

.count-nav {
  width: 100%;
  font-size: 40px;
  height: 90px;
  font-family: taiwaiFont;
}

.count-text {
  top: 0;
  right: 50%;
  width: 960px;
  margin-right: -960px;
  font-size: 15px;
  height: 42px;
  span:nth-child(1) {
    margin-left: 50px;
  }
  span {
    width: 100px;
  }
  span.flex-center {
    width: 60px;
  }
}

.count-infos {
  /* 限定大小 */
  min-width: 1024px;
  max-width: 1920px;
  max-height: 100vh;
  margin: 0 auto;
  background: url(../../assets/count/head_bg.png) no-repeat 0 0 / contain;
  display: flex;
  padding: 68px 20px 20px 20px;
  overflow: hidden;

  .item-column {
    flex: 3;
  }
  .item-column:nth-child(2) {
    flex: 4;
    margin: 40px 10px 0 10px;
  }
  .common-panel {
    /* 边框 */
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    box-sizing: border-box;
    border: 2px solid red;
    border-image: url(../../assets/count/border.png) 51 38 21 132;
    border-width: 2.125rem 1.583rem 0.875rem 5.5rem;
  }
  .common-title {
    left: -10px;
  }
  .count-list {
    .item-chlid {
      text-align: center;
      margin-top: 5px;
      .text {
        font-size: 12px;
        color: #4c9bfd;
      }
    }
  }
  .count-list.technician {
    .item-chlid {
      width: 25%;
      .num {
        width: 80px;
        height: 80px;
        margin: 0 auto 8px auto;
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        font-family: electronicFont;
        font-size: 24px;
        color: #fff32b;
      }
      .num:before {
        position: absolute;
        width: 100%;
        height: 100%;
        content: '';
        background: url(../../assets/count/img1.png) center center;
        border-radius: 80px;
        background-size: 100% 100%;
        opacity: 0.4;
        left: 0;
        top: 0;
        animation: myfirst2 15s infinite linear;
      }

      .num:after {
        position: absolute;
        width: 86%;
        background: url(../../assets/count/img2.png) center center;
        border-radius: 80px;
        background-size: 100% 100%;
        opacity: 0.4;
        height: 86%;
        content: '';
        left: 7%;
        top: 7%;
        animation: myfirst 15s infinite linear;
      }
    }
  }
  .count-list.order {
    .item-chlid {
      .num {
        font-size: 24px;
        font-weight: bold;
        color: #fff;
        margin-bottom: 8px;
      }
    }
  }
  .content {
    flex: 1;
    display: none;
    position: relative;
    .marquee-view {
      position: absolute;
      top: 1.6rem;
      bottom: 0;
      width: 100%;
      overflow: hidden;

      .row {
        line-height: 1.05;
        padding: 0.5rem 1.5rem;
        color: #61a8ff;
        font-size: 0.5rem;
        position: relative;
        display: flex;
        justify-content: space-between;
      }
      .row:hover {
        color: #68d8ff;
        background: rgba(255, 255, 255, 0.1);
      }
      .row:hover .icon-dot {
        opacity: 1;
      }

      .icon-dot {
        position: absolute;
        left: 0.64rem;
        opacity: 0;
      }
    }
  }
}

/* 加载旋转动画 */
#load {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 999;
  .load_img {
    position: absolute;
    left: calc(50% - 182px);
    top: calc(50% - 182px);
    img {
      position: absolute;
      left: 0;
      top: 0;
    }
    .jzxz1 {
      animation: xz1 8s infinite linear;
    }
    .jzxz2 {
      animation: xz2 7s infinite linear;
    }
  }
}
@keyframes xz1 {
  from {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(180deg);
  }
  to {
    transform: rotate(360deg);
  }
}
@keyframes xz2 {
  from {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(-180deg);
  }
  to {
    transform: rotate(-360deg);
  }
}

@keyframes myfirst {
  to {
    transform: rotate(-360deg);
  }
}
@keyframes myfirst2 {
  to {
    transform: rotate(360deg);
  }
}
@media screen and (max-width: 1600px) {
  .top span {
    transform: scale(0.9);
  }
  .top .province ul.sup li {
    padding: 0.4rem 0.5rem;
  }
  .top .province ul.sub li {
    padding: 0.23rem 0.5rem;
  }
  .quarter span {
    transform: scale(0.9);
  }
}
</style>
